﻿using System;
using System.Reflection;

namespace Borg
{
    internal class DelegateInvoker : IActionInvoker
    {
        private readonly Delegate _delegate;
        private readonly object[] _args;

        public object Target
        {
            get { return _delegate.Target; }
        }

        public MethodInfo Method
        {
            get { return _delegate.Method; }
        }

        public object[] Args
        {
            get { return _args; }
        }

        public DelegateInvoker(Delegate @delegate, params object[] args)
        {
            _delegate = @delegate;
            _args = args;
        }

        public void Invoke()
        {
            _delegate.DynamicInvoke(_args);
        }
    }
}
